﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Bzure.Common.Core;
using Bzure.Mvc.Controllers;

namespace Bzure.Mvc.Html
{
    public static class MenuFlagHelperExtensions
    {
        //public static MvcHtmlString ProductImageRouteLink(this HtmlHelper htmlHelper, Product product, string routeName, int Width = 135, int Height = 135, object htmlAttributes = null)
        //{
        //    MvcHtmlString str = htmlHelper.RouteLink("{0}", routeName, new { ProductID = product.ID }, htmlAttributes);

        //    MvcHtmlString ImageHtml = MvcHtmlString.Create(string.Format(@"<img alt='{0}' src='{0}' width='{1}' height='{2}' />", product.MasterImage, Width, Height));
        //    return MvcHtmlString.Create(string.Format(str.ToHtmlString(), ImageHtml));
        //}

        public static MvcHtmlString MenuFlag(this HtmlHelper htmlHelper, string MenuFlag, string OutHtml)
        {
            string html = string.Empty;
            List<string> flag = htmlHelper.ViewContext.Controller.ViewBag._bzureMvcMenuFlag;
            if (flag.IsNotNullAndEmpty() && flag.Contains(MenuFlag, StringComparer.OrdinalIgnoreCase))
            {
                html = OutHtml;
            }
            return MvcHtmlString.Create(html);
        }
        public static ControllerMenu[] ControllerMenus(this HtmlHelper htmlHelper)
        {
            List<ControllerMenu> menus = htmlHelper.ViewContext.Controller.ViewBag._bzureControllerMenus;
            if (menus.IsNullOrEmpty())
                return new List<ControllerMenu>().ToArray();
            return menus.ToArray();
        }
    }
}
